<template>
  <div class="container">
    <div class="header">
      <h1>顾客出诊记录详情</h1>
      <p>瑶芳清颜 · 专业护理档案</p>
    </div>
    
    <!-- 顾客基本信息卡片 -->
    <div class="card">
      <h2 class="card-title">
        <i class="fas fa-user-circle"></i> 顾客基本信息
      </h2>
      <div class="info-grid">
        <div class="info-item">
          <div class="info-label">顾客姓名</div>
          <div class="info-value">
            {{ customerInfo.name }}
            <span class="badge badge-primary">{{ customerInfo.membership }}</span>
          </div>
        </div>
        <div class="info-item">
          <div class="info-label">性别/年龄</div>
          <div class="info-value">{{ customerInfo.gender }} / {{ customerInfo.age }}岁</div>
        </div>
        <div class="info-item">
          <div class="info-label">手机号码</div>
          <div class="info-value">{{ customerInfo.phone }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">来源渠道</div>
          <div class="info-value">
            {{ customerInfo.channel }}
            <span v-if="customerInfo.isNewCustomer" class="badge badge-success">新客首单</span>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 服务信息卡片 -->
    <div class="card">
      <h2 class="card-title">
        <i class="fas fa-clipboard-list"></i> 服务信息
      </h2>
      <div class="info-grid">
        <div class="info-item">
          <div class="info-label">咨询项目</div>
          <div class="info-value">{{ serviceInfo.project }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">服务套餐</div>
          <div class="info-value">{{ serviceInfo.package }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">当前进度</div>
          <div class="info-value">
            {{ serviceInfo.progress }}
            <span class="badge badge-primary">{{ serviceInfo.status }}</span>
          </div>
        </div>
        <div class="info-item">
          <div class="info-label">验券时间</div>
          <div class="info-value">{{ formatDateTime(serviceInfo.verificationTime) }}</div>
        </div>
      </div>
    </div>
    
    <!-- 服务人员信息卡片 -->
    <div class="card">
      <h2 class="card-title">
        <i class="fas fa-user-tie"></i> 服务人员信息
      </h2>
      <div class="info-grid">
        <div class="info-item">
          <div class="info-label">店长</div>
          <div class="info-value">{{ staffInfo.manager }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">操作技师</div>
          <div class="info-value">{{ staffInfo.technician }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">出诊时间</div>
          <div class="info-value">
            {{ formatDateTime(staffInfo.startTime) }} ～ {{ formatTime(staffInfo.endTime) }}
          </div>
        </div>
        <div class="info-item">
          <div class="info-label">护理时长</div>
          <div class="info-value">{{ staffInfo.duration }}</div>
        </div>
      </div>
    </div>
    
    <!-- 效果对比照片卡片 -->
    <div class="card">
      <h2 class="card-title">
        <i class="fas fa-images"></i> 效果对比照片
      </h2>
      <div class="photo-section">
        <p>顾客已授权使用以下照片用于效果展示及服务记录</p>
        
        <div class="photo-grid">
          <div class="photo-card" v-for="photo in photos" :key="photo.type">
            <img :src="photo.imageUrl" :alt="photo.title">
            <div class="photo-meta">
              <div class="photo-title">{{ photo.title }}</div>
              <div class="photo-date">上传时间: {{ photo.uploadTime || '无' }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 备注信息卡片 -->
    <div class="card">
      <h2 class="card-title">
        <i class="fas fa-edit"></i> 备注
      </h2>
      <div class="info-item">
        <div class="info-value" style="border-bottom: none; padding: 15px; background-color: var(--light-color); border-radius: 5px;">
          <p>{{ notes }}</p>
        </div>
      </div>
    </div>
    
    <div style="text-align: center;">
      <a href="#" class="btn-back" @click.prevent="goBack">
        <i class="fas fa-arrow-left"></i> 返回顾客列表
      </a>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

// 顾客基本信息
const customerInfo = ref({
  name: '梁璇',
  gender: '女',
  age: 28,
  phone: '138****5678',
  channel: '美团',
  membership: '普通会员',
  isNewCustomer: true
});

// 服务信息
const serviceInfo = ref({
  project: '腋下小部位脱毛',
  package: '冰点脱毛 · 腋下脱毛单次',
  progress: '腋下脱毛单次',
  status: '已完成',
  verificationTime: '2025-05-11T14:56:00'
});

// 服务人员信息
const staffInfo = ref({
  manager: '欣欣（技术店长）',
  technician: '欣欣（技术店长）',
  startTime: '2025-05-11T14:40:00',
  endTime: '2025-05-11T15:00:00',
  duration: '约20分钟'
});

// 照片对比
const photos = ref([
  {
    type: 'before',
    title: '护理前照片',
    imageUrl: 'https://images.unsplash.com/photo-1605497788054-5f8f3a1b9e6a?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80',
    uploadTime: ''
  },
  {
    type: 'after',
    title: '护理后照片',
    imageUrl: 'https://images.unsplash.com/photo-1605497788054-5f8f3a1b9e6a?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80',
    uploadTime: ''
  }
]);

// 备注信息
const notes = ref('顾客皮肤较为敏感，本次使用低能量模式，护理后轻微发红，敷用镇静凝胶后症状缓解。');

// 格式化日期时间
const formatDateTime = (dateString) => {
  if (!dateString) return '';
  const date = new Date(dateString);
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    hour12: false
  }).replace(/\//g, '-');
};

// 仅格式化时间部分
const formatTime = (dateString) => {
  if (!dateString) return '';
  const date = new Date(dateString);
  return date.toLocaleString('zh-CN', {
    hour: '2-digit',
    minute: '2-digit',
    hour12: false
  });
};

// 返回按钮点击事件
const goBack = () => {
  router.go(-1);
};
</script>

<style scoped>
:root {
  --primary-color: #8e6c88;
  --secondary-color: #d4b8c7;
  --accent-color: #a78a7f;
  --light-color: #f9f5f8;
  --dark-color: #3d3d3d;
  --success-color: #7d9b7e;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  font-family: 'Noto Sans SC', sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
  background-color: #fafafa;
  color: var(--dark-color);
  line-height: 1.6;
}

.header {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
}

.header h1 {
  color: var(--primary-color);
  font-weight: 500;
  font-size: 28px;
  margin-bottom: 10px;
}

.header::after {
  content: "";
  display: block;
  width: 100px;
  height: 3px;
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  margin: 15px auto;
}

.card {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  padding: 30px;
  margin-bottom: 30px;
}

.card-title {
  color: var(--primary-color);
  font-size: 20px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--secondary-color);
  display: flex;
  align-items: center;
}

.card-title i {
  margin-right: 10px;
  font-size: 24px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.info-item {
  margin-bottom: 15px;
}

.info-label {
  font-weight: 500;
  color: var(--accent-color);
  margin-bottom: 5px;
  font-size: 14px;
}

.info-value {
  font-size: 16px;
  color: var(--dark-color);
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}

.photo-section {
  margin-top: 30px;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 20px;
}

.photo-card {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease;
}

.photo-card:hover {
  transform: translateY(-5px);
}

.photo-card img {
  width: 100%;
  height: 300px;
  object-fit: cover;
}

.photo-meta {
  padding: 15px;
  background-color: white;
}

.photo-title {
  font-weight: 500;
  color: var(--primary-color);
  margin-bottom: 5px;
}

.photo-date {
  font-size: 13px;
  color: #888;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 10px;
}

.badge-primary {
  background-color: var(--secondary-color);
  color: var(--primary-color);
}

.badge-success {
  background-color: #e8f5e9;
  color: var(--success-color);
}

.btn-back {
  display: inline-block;
  padding: 10px 20px;
  background-color: var(--light-color);
  color: var(--primary-color);
  border: 1px solid var(--secondary-color);
  border-radius: 5px;
  text-decoration: none;
  font-weight: 500;
  margin-top: 30px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.btn-back:hover {
  background-color: var(--primary-color);
  color: white;
}

@media (max-width: 768px) {
  .photo-grid {
    grid-template-columns: 1fr;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
  }
}
</style>